var app=getApp();
Page({
  onShow:function(){
    // 生命周期函数--监听页面初次渲染完成
    wx.setNavigationBarTitle({
       title: '仿百思笑话',
    })
  },
  data:{
    result:[],
    index:1,
    // 经典笑话的数据
    resultClascial:[],
    maxtime:"",
  },
  onLoad:function(){
    this.netForClasscialFun()
  },
  // 经典笑话第一次加载
  netForClasscialFun:function(){
    var that = this;
    app.showHud()
    wx.request({
      url: 'http://api.budejie.com/api/api_open.php',
      data: {
        a:'list',
        c:'data',
        type:29,
        maxtime:that.data.maxtime,
      },
      header: {
      },
      success: function(res) {
        console.log("classcial=====success")
        console.log(res.data.list)
        that.setData({
          resultClascial:res.data.list,
          maxtime:res.data.info.maxtime,
        })
      },
      fail: function (res) {
        console.log("failed")
        that.setData({
        })
      }
    })
  },
  // 经典笑话上拉加载
  lowerClasscial:function(){
     var that = this;
     app.showHud()
     wx.request({
      url: 'http://api.budejie.com/api/api_open.php',
      data: {
        a:'list',
        c:'data',
        type:29,
        maxtime:that.data.maxtime,
      },
      
      header: {
      },
      
      success: function(res) {
        console.log("classcial=====success===more")
        console.log(that.data.maxtime)
        that.setData({
          resultClascial:that.data.resultClascial.concat(res.data.list),
          maxtime:res.data.info.maxtime
        })
      },
      fail: function (res) {
        console.log("failed")
      }
    })
  },
  // 经典笑话下拉刷新
  upperClasscial:function(){
    var that=this
     that.setData({
        maxtime:"",
     })
     that.netForClasscialFun()
  },
  // 网络请求失败
  loadAgain:function(){
    this.netForClasscialFun()
  }
})